package com.mvp.shq.washer.ui.shop.productDetail;

import com.mvp.shq.washer.entity.result.BaseResult;
import com.mvp.shq.washer.entity.shop.CollectResponse;
import com.mvp.shq.washer.entity.shop.Product;
import com.mvp.shq.washer.http.RxSchedulers;
import com.mvp.shq.washer.http.ShopApi;

import java.util.List;

import io.reactivex.Observable;

/**
 * Created by Administrator on 2017/10/10.
 */

public class Model implements ProductDetailConstract.Model {
    @Override
    public Observable<BaseResult<Product>> getProductDetail(String userId,String productId) {
        return ShopApi.getInstance().service
                .getProductInfoBySku(userId,productId)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<Product>> getProductDetailBySpu(String userId,String productId) {
        return ShopApi.getInstance().service
                .getProductInfo(userId,productId)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<Product>> getProductByAttr(String productId, String attrs) {
        return ShopApi.getInstance().service
                .getProductByAttr(productId,attrs)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<String>> collectProduct(String token, String userId, List<CollectResponse> list) {
        return ShopApi.getInstance().service
                .addCollect(token,userId,list)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<String>> delProduct(String token, String userId, String productId) {
        return ShopApi.getInstance().service
                .delCollect(token,userId,productId)
                .compose(RxSchedulers.io_main());
    }
}
